package org.de.maeyer.unit;

/**
 * This interface provides an abstraction of a unit, and a notion of conversion between units.
 * 
 * @author Peter De Maeyer
 */
public interface Unit {

	/**
	 * @return the full name of this unit. As a convention, the name should always be singular, so it should be <code>meter</code> instead of
	 *         <code>meters</code>.
	 */
	String getName();

	/**
	 * @return the symbol of this unit. For meter, the symbol would be <code>m</code>.
	 */
	String getSymbol();

	/**
	 * Converts a given value from a given unit to this unit.
	 * 
	 * @param value
	 *            the value to convert.
	 * @param unit
	 *            the unit to convert from.
	 * @return the converted value.
	 * @throws ArithmeticException
	 *             when the given unit and this unit mismatch (are incompatible). For instance, <code>meter</code> and <code>second</code> mismatch, but
	 *             <code>minute</code> and <code>hour</code> do not because they are both units of time.
	 */
	double convertFrom(double value, Unit unit);
}
